<template>
  <div id="person">
    <div class="wrapper">
      <top-bar></top-bar>
      <top-header></top-header>
      <div class="main">
        <div class="main-content">
          <div class="content-lf">
            <div class="avatar-box">
              <img :src="info.imageUrl"
                   alt=""
                   class="avatar-img">
              <span class="lv-icon lv-d"></span>
            </div>
            <p class="hero-box">
              <span class="hero-icon"></span>
              英雄出处
            </p>
            <table class="hero-info">
              <tbody>
                <tr>
                  <td>姓名：{{ staffName }}</td>
                  <td>等级：{{ info.levelName }}级</td>
                </tr>
                <tr>
                  <td>组别：{{ info.groupName }}</td>
                  <td>目前项目：{{ info.projectCount }}个</td>
                </tr>
                <tr>
                  <td colspan="2">空闲时间段：<span v-if="info.endTime == '1970-01-01 00:00:00'"
                          class="date-time">{{getTime(info.startTime)}} 之后</span><span v-if="info.endTime&& info.endTime!= '1970-01-01 00:00:00'"
                          class="date-time">{{getTime(info.startTime)}}至{{getTime(info.endTime)}}</span></td>
                </tr>
                <tr>
                  <td colspan="2">职位：{{info.positionName}}</td>
                </tr>
              </tbody>
            </table>
          </div>
          <div class="content-rg">
            <p class="rg-title work-title">
              <span class="title-icon work-icon"></span>
              正在为之努力
            </p>
            <div class="work-box">
              <router-link :to="{ path:'/projects/project',query:{'id': item.id} }"
                           tag="div"
                           class="box-item"
                           v-for="item in info.doingProject"
                           :key="item.id">
                <el-popover placement="bottom"
                            width="180px"
                            trigger="hover">
                  <div class="work-info">
                    <p>项目名称：{{ item.projectName }}</p>
                    <p>项目等级：{{ item.levelName }}级</p>
                    <p>项目类型：{{ item.typeName }}</p>
                    <p>项目阶段：{{ item.phaseName }}</p>
                  </div>
                  <div class="work-item"
                       slot="reference"><img v-if="item.imageUrls[0]"
                         :src="item.imageUrls[0].url"
                         alt=""
                         class="item-img"></div>
                </el-popover>
              </router-link>
            </div>
            <p class="rg-title work-title">
              <span class="title-icon score-icon"></span>
              历史战绩
            </p>
            <div class="score-box">
              <div class="score-item"
                   v-for="(task, index) in info.finishedProject"
                   :key="index">
                <img :src="task.imageUrls[0].url"
                     alt=""
                     class="item-img">
              </div>
              <div v-if="!info.finishedProject.length"
                   class="no-score">当前历史战绩为空</div>
            </div>
            <p class="rg-title work-title">
              <span class="title-icon rank-icon"></span>
              英雄排名
            </p>
            <div class="rank-box">
              <table style="border-collapse:collapse;">
                <tr>
                  <td>分值：{{ info.totalScore }}</td>
                  <td>奖金：{{ info.bonus }}</td>
                  <td>排名：{{ info.rank }}</td>
                </tr>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
    <bottom-tab class="bottom-bar"></bottom-tab>
  </div>
</template>

<script>
import topBar from '@/components/top-bar'
import topHead from '@/components/top-head'
import bottomTab from '@/components/bottom-tab'

let CONSTANT = require("../../constant/constant.js");
let common = require("../../common.js");

    export default {
        components: {
			'top-bar': topBar,
			'top-header': topHead,
			'bottom-tab': bottomTab
		},
        data() {
            return {
                id: '',
                staffName: this.$router.currentRoute.query.name?this.$router.currentRoute.query.name:'',
                info: {
                    imageUrl: '',
                    doingProject: [],
                    taskList: [],
                    startTime: '',
                    endTime: '',
                    finishedProject: []
                }
            }
        },
        mounted() {
            this.id  = this.$router.currentRoute.query.id;
            if(this.id){
                this.getDetail(); 
            }
        },
        methods: {
            getDetail() {
                let url = CONSTANT.URL.HERO.GETHEROBYID;
                let data = {
                    id: this.id
                }
                common.requestAjax(url,JSON.stringify(data),null,(res)=>{
                    let info = res.data.bussData
                    this.info = {
                        id: info.id,
                        imageUrl: info.imageUrl,
                        levelName: info.levelName,
                        groupName: info.groupName,
                        projectCount: info.projectCount,
                        startTime: info.startTime,
                        endTime: info.endTime,
                        doingProject: info.doingProject,
                        taskList: info.taskDTOS,
                        totalScore: info.totalScore,
                        rank: info.rank,
                        bonus: info.bonus,
                        finishedProject:info.finishedProject,
                        positionName:info.positionName
                    }
                })
            },
            getLv(level) {
                switch (level) {
                    case 'A':
                    return 'lv-a'
                    break;
                    case 'B':
                    return 'lv-b'
                    break;
                    case 'C':
                    return 'lv-c'
                    break;
                    case 'D':
                    return 'lv-d'
                    break;
                    case 'S':
                    return 'lv-s'
                    break;
                }
            },
            getTime(time) {
				return time.slice(5, 10)
            },
        }
    }
</script>

<style scoped>
#person {
    position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: auto;
}
.wrapper {
    min-height: calc(100vh - 210px);
	padding-bottom: 210px;
    background-color: rgba(245,245,245,1);
}
.bottom-bar {
	position: relative;
    left: 0;
    bottom: 0;
    margin-top: -210px;
    clear: both;
}
.main {
    padding-top: 30px;
    padding-bottom: 60px;
}
.main-content {
    width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px 30px 30px 20px;
    display: flex;
    justify-content: space-between;
}
.content-lf {
    width: 260px;
}
.content-rg {
    width: 860px;
}
.avatar-box {
    width: 200px;
    height: 200px;
    position: relative;
    display: inline-block;
}
.avatar-box .avatar-img {
    width: 200px;
    height: 200px;
    display: inline-block;
    /* background: url(../../assets/project_bg.png) no-repeat 100% 100%; */
    /* background-size: auto; */
}
.avatar-box .lv-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 35px;
    height: 35px;
}
.lv-a {
    background: url(../../assets/lv_a.png) no-repeat 100% 100%;
    background-size: cover;
}
.lv-b {
    background: url(../../assets/lv_b.png) no-repeat 100% 100%;
    background-size: cover;
}
.lv-c {
    background: url(../../assets/lv_c.png) no-repeat 100% 100%;
    background-size: cover;
}
.lv-d {
    background: url(../../assets/lv_d.png) no-repeat 100% 100%;
    background-size: 100% 100%;
}
.lv-s {
    background: url(../../assets/lv_s.png) no-repeat 100% 100%;
    background-size: cover;
}

.hero-box {
    margin-top: 10px;
    margin-bottom: 20px;
    height: 32px;
    line-height: 32px;
    font-size:18px;
}
.hero-box .hero-icon {
    width: 32px;
    height: 32px;
    display: inline-block;
    margin-right: 10px;
    background: url(../../assets/hero_icon.png) no-repeat 100% 100%;
    background-size: cover;
    vertical-align: middle;
}
.hero-info {
    border-collapse:collapse;
    font-size:14px;
}
.hero-info td {
    border: 1px solid #ddd;
    padding-left: 15px;
    height: 40px;
    width: 130px;
    line-height: 40px;
    font-size:14px;
    color:rgba(51,51,51,1);
}
.rg-title {
    margin-bottom: 12px;
    height: 32px;
    line-height: 32px;
    font-size:18px;
    color:rgba(195,24,31,1);
}
.rg-title .title-icon {
    width: 32px;
    height: 32px;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
}
.title-icon.work-icon {
    background: url(../../assets/work_icon.png) no-repeat 100% 100%;
    background-size: cover;
}
.title-icon.score-icon {
    background: url(../../assets/score_icon.png) no-repeat 100% 100%;
    background-size: cover;
}
.title-icon.rank-icon {
    background: url(../../assets/rank_icon.png) no-repeat 100% 100%;
    background-size: cover;
}
.work-box,
.score-box {
  width: 860px;
  padding-bottom: 40px;
  display: flex;
  flex-wrap: wrap;
  /* justify-content: space-between; */
}
.work-info {
    /* padding-bottom: 10px; */
}
.work-info p{
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    padding-right: 100px;
    color: #000;
}
.box-item {
    width: 124px;
    height: 124px;
    margin-top: 20px;
    margin-right: 18px;
}
.work-item {
    width: 124px;
    height: 124px;
}
.score-item {
    width: 124px;
    height: 124px;
    margin-top: 20px;
    margin-right: 18px;
}
.item-img {
    display: inline-block;
    width: 124px;
    height: 124px;
    background: url(../../assets/project_bg.png) no-repeat 100% 100%;
    background-size: 100% 100%;
}
.rank-box td {
    width:207px;
    height:60px;
    line-height: 60px;
    text-align: center;
    border: 1px solid #ddd;
}
</style>